import {
  API_DOMAIN
} from './api.config'
const fetch = require('./fetch')
/**
 * @param  {String} 接口地址
 * @param  {Objece} params 接口参数参数
 */
function fetchApi(action, params, method) {
  return fetch(API_DOMAIN, action, params, method)
}

/**
 * 用户登录接口
 * @param {object} 接口参数
 * @returns
 */
function Login(params) {
  return fetchApi('User/login', params).then(res => res.data)
}

/**
 * 
 * @param {object} 联合登录
 * @returns
 */
function unionLoginNew(params) {

  params.channelName = 'applet';
  return fetchApi('api/unionLoginNew', params).then(res => res.data)
}

/**
 * 
 * @param {object} 获取活动信息
 * @returns
 */
function searchById(params) {

  return fetchApi('api/searchById', params).then(res => res.data)
}


/**
 * 
 * @param {object} 静态获取活动信息
 * @returns
 */
function searchByIdSatic(params) {

  params.static = true;

  var itemUrl = '/' + params.id + '/detail.json'

  return fetchApi(itemUrl, {
    static: true
  }).then(res => res.data)
}



/**
 * 
 * @param {object} 查询已获取的预约码列表
 * *reservationId
 * @returns
 */
function queryReservationCodes(params) {

  return fetchApi('api/queryReservationCodes', params).then(res => res.data)
}


/**
 * 
 * @param {object} 查询单个预约码
 * *reservationId
 * @returns
 */
function queryReservationCode(params) {

  return fetchApi('api/queryReservationCode', params).then(res => res.data)
}



/**
 * 
 * @param {object} 领取预约码
 * *reservationId
 * @returns
 */
function applyReservationCode(params) {

  return fetchApi('api/applyReservationCode', params).then(res => res.data)
}

/**
 * 
 * @param {object} 获取资产包详情
 * *reservationId
 * @returns
 */
function queryPackageAssetInfo(params) {

  return fetchApi('api/queryPackageAssetInfo', params).then(res => res.data)
}


/**
 * 
 * @param {object} 获取资产详情
 * *reservationId
 * @returns
 */
function queryReservationAsset(params) {

  return fetchApi('api/queryReservationAsset', params).then(res => res.data)
}


/**
 * 
 * @param {object} 获取分享二维码
 * *reservationId
 * @returns
 */
function getQRCode(params) {
  params.channelName = 'applet';

  return fetchApi('api/getQRCode', params).then(res => res.data)
}


/**
 * 
 * @param {object} 获取活动列表
 * *reservationId
 * @returns
 */
function queryReservationForPage(params) {

  return fetchApi('api/queryReservationForPage', params).then(res => res.data)
}

/**
 * 
 * @param {object} 获取静态活动列表
 * *reservationId
 * @returns
 */
function queryReservationForPageStatic(params) {
  params.static = true;

  return fetchApi('/789/weiapplet.json', {
    static: true
  }).then(res => res.data)
}

/**
 * 
 * @param {object} 获取三方系统时间
 * *reservationId
 * @returns
 */
function getCurrentTime() {

  return fetchApi('https://quan.suning.com/getSysTime.do', {}).then(res => res.data)
}


/**
 * 
 * @param {object} 效验登录状态
 * *reservationId
 * @returns
 */
function isLogin(params) {

  return fetchApi('api/isLogin', params).then(res => res.data)
}




/**
 * 
 * @param {object} 获取活动列表
 * *reservationId
 * @returns
 */
function countUserReservationCode(params) {

  return fetchApi('api/countUserReservationCode', params).then(res => res.data)
}

/**
 * 
 * @param {object} 获取活动可购买数量
 * *reservationId
 * @returns
 */
function queryReservationPartakeNumber(params) {

  return fetchApi('api/queryReservationPartakeNumber', params).then(res => res.data)
}

/**
 * 
 * @param {object} 获取DAC列表
 * *reservationId
 * @returns
 */
function queryUserPackageAssetList(params) {

  return fetchApi('api/queryUserPackageAssetList', params).then(res => res.data)
}

/**
 * 
 * @param {object} 增加预约次数
 * *reservationId
 * @returns
 */
function addReservationAccessCount(params) {

  return fetchApi('api/addReservationAccessCount', params).then(res => res.data)
}


/**
 * 
 * @param {object} 消息订阅接口
 * *reservationId
 * @returns
 */
function subscribeWeChatMsg(params) {

  return fetchApi('api/subscribeWeChatMsg', params).then(res => res.data)
}




/**
 * 
 * @param {object} 获取活动配置
 * *reservationId
 * @returns
 */
function smproGetCongig(params) {
  return fetchApi('/smpro/config.json', {
    static: true
  }).then(res => res.data)

}

/**
 * 
 * @param {object} 消息类型
 * *reservationId
 * @returns
 */
function readMsg(params) {

  return fetchApi('api/readMsg', params).then(res => res.data)
}


/**
 * 
 * @param {object} 验证码获取
 * *reservationId
 * @returns
 */
function loginCode(params) {

  return fetchApi('app/appUser/loginCode', params).then(res => res.data)
}

/**
 * 
 * @param {object} 用户登录
 * *reservationId
 * @returns
 */
function mobleLogin(params) {

  return fetchApi('app/appUser/login', params).then(res => res.data)
}

/**
 * 
 * @param {object} 微信登录
 * *reservationId
 * @returns
 */
function weChatLogin(params) {

  return fetchApi('app/appUser/weChatLogin', params, 'post').then(res => res.data)
}



/**
 * 
 * @param {object} 获取用户登录
 * *reservationId
 * @returns
 */
function getUserInfo(params) {

  return fetchApi('app/appUser/getUserInfo', params, "get").then(res => res.data)
}

/**
 * 
 * @param {*} 老师课堂列表 
 */
function getTeacherCourset(params) {
  return fetchApi('app/course/teacherCourse', params, "post").then(res => res.data)
}

/**
 * 
 * @param {班级课堂记录} params 
 */
function getTeacherCoursetInfo(params) {
  return fetchApi('app/course/record/info', params, "post").then(res => res.data)
}

/**
 * 
 * @param {班级课堂记录-学生列表} params 
 */
function getCoursetStuList(params) {
  return fetchApi('app/course/student/list', params, "post").then(res => res.data)
}

/**
 * 
 * @param {班级课堂记录-学生个人详情} params 
 */
function getCoursetStuInfo(params) {
  return fetchApi('app/course/student', params, "post").then(res => res.data)
}

/**
 * 
 * @param {学生课堂记录列表} params 
 */
function getStudentCourse(params) {
  return fetchApi('app/course/studentCourse', params, "post").then(res => res.data)
}

/**
 * 
 * @param {学生课堂风采} params 
 */
function gesTudentPicture(params) {
  return fetchApi('app/course/studentPicture', params, "post").then(res => res.data)
}

/**
 * 
 * @param {课堂记录-老师个人详情} params 
 */
function getTeacherStudentInfo(params) {
  return fetchApi('app/course/teacherStudent', params, "post").then(res => res.data)
}

/**
 * 
 * @param {object} 作业列表
 * *reservationId
 * @returns
 */
function homeworkList(params) {
  return fetchApi('app/homework/list', params, "post").then(res => res.data)
}


/**
 * 
 * @param {object} 退出登录
 * *reservationId
 * @returns
 */
function loginOut() {
  return fetchApi('app/appUser/loginOut', {}, "get").then(res => res.data)
}

/**
 * 
 * @param {object} 解绑学生
 * *reservationId
 * @returns
 */
function unboundStudent(params) {
  return fetchApi('app/appUser/unboundStudent', params, "post").then(res => res.data)
}

/**
 * 
 * @param {object} 绑定学生
 * *reservationId
 * @returns
 */
function bindingStudent(params) {
  return fetchApi('app/appUser/bindingStudent', params, "post").then(res => res.data)
}

/**
 * 
 * @param {object} 根据班级Id查找班级信息
 * *reservationId
 * @returns
 */
function getClassInfo(params) {
  return fetchApi('app/appUser/getClassInfo', params, "post").then(res => res.data)
}
/**
 * 
 * @param {object} 切换身份
 * *reservationId
 * @returns
 */
function updateUserType(params) {
  return fetchApi('app/appUser/updateUserType', params, "post").then(res => res.data)
}

/**
 * 
 * @param {object} 课堂记录-班级参数标准
 * *reservationId
 * @returns
 */
function standard(params) {
  return fetchApi('app/course/standard', params, "post").then(res => res.data)
}


/**
 * 
 * @param {object} 获取校区
 * *reservationId
 * @returns
 */
function getSchoolArea() {
  return fetchApi('app/common/schoolArea', {}, "get").then(res => res.data)
}

/**
 * 
 * @param {object} 编辑头像
 * *reservationId
 * @returns
 */
function updateUserPicUrl(params) {
  return fetchApi('app/appUser/updateUserPicUrl', params, "post").then(res => res.data)
}

/**
 * 
 * @param {object} 获取校区下 班级类型，学段，年级，班级列表
 * *reservationId
 * @returns
 */
function getClassInfos(params) {
  return fetchApi('app/common/class', params, "post").then(res => res.data)
}


/**
 * 
 * @param {object} 发布作业
 * *reservationId
 * @returns
 */
function applyWork(params) {
  return fetchApi('app/homework/publish', params, "post").then(res => res.data)
}
/*
 * @param {object} 学生个人运动处方数据
 * *reservationId
 * @returns
 */
function getPrescription(params) {
  return fetchApi('app/course/prescription', params, "post").then(res => res.data)
}


/**
 * 
 * @param {object} 获取教学周期
 * *reservationId
 * @returns
 */
function getTeachCycle() {
  return fetchApi('app/common/teachCycle', {}, "POST").then(res => res.data)
}

/**
 * 
 * @param {object} 获取体测周期
 * *reservationId  0 课堂体测 周期，1 体育考试周 期，2 国家体测成绩上 报周期
 * @returns
 */
function getTestCycle(params) {
  return fetchApi('app/common/testCycle', params, "POST").then(res => res.data)
}

/**
 * 
 * @param {object} 获取体测周期
 * *reservationId  0 课堂体测 周期，1 体育考试周 期，2 国家体测成绩上 报周期
 * @returns
 */
function getPrescriptionDetail(params) {
  return fetchApi('app/course/prescriptionDetail', params, "POST").then(res => res.data)
}

/**
 * 
 * @param {object} 处方学生列表
 * *reservationId  
 * @returns
 */
function getStuList(params) {
  return fetchApi('app/sportsplan/list', params, "POST").then(res => res.data)
}


/**
 * 
 * @param {object} 老师-学生个人运动处方
 * *reservationId
 * @returns
 */
function getTeacherPrescription(params) {
  return fetchApi('app/course/teacherPrescription', params, "post").then(res => res.data)
}

/**
 * 
 * @param {object} 学生个人运动处方详情
 * *reservationId
 * @returns
 */
function getTeacherPrescriptionDetail(params) {
  return fetchApi('app/course/teacherPrescriptionDetail', params, "post").then(res => res.data)
}

/**
 * 
 * @param {object} 家长-学生体质健康报告
 * *reservationId
 * @returns
 */
function getPhysicalReportStu(params) {
  return fetchApi('app/physicalReport/students', params, "post").then(res => res.data)
}


/**
 * 
 * @param {object} 老师-班级体质健康报告
 * *reservationId
 * @returns
 */
function getPhysicalReportClass(params) {
  return fetchApi('app/physicalReport/class', params, "post").then(res => res.data)
}


/**
 * 
 * @param {object} 老师-学生体质健康报告
 * *reservationId
 * @returns
 */
function getPhysicalReportTheacher(params) {
  return fetchApi('app/physicalReport/student', params, "post").then(res => res.data)
}

/**
 * 
 * @param {object} 学生获取作业详情
 * *reservationId
 * @returns
 */
function getHomeWorkDetail(params) {
  return fetchApi('app/homework/detail', params, "post").then(res => res.data)
}


/**
 * 
 * @param {object} 家长首页
 * *reservationId
 * @returns
 */
function getParentList() {
  return fetchApi('app/index/parentList', {}, "POST").then(res => res.data)
}


/**
 * 
 * @param {object} 老师首页11
 * *reservationId
 * @returns
 */
function getTeacherLis() {
  return fetchApi('app/index/teacherList', {}, "POST").then(res => res.data)
}

/**
 * 删除作业
 * @param {*} params 
 */
function delHomework(params) {
  return fetchApi('app/homework/delete/' + params, {}, "get").then(res => res.data)
}

/**
 * 编辑作业
 * @param {*} params 
 */
function editHomeWork(params) {
  return fetchApi('app/homework/edit', params, "post").then(res => res.data)
}

/**
 * 老师作业详情
 * @param {} params 
 */
function getHomeworkInfo(params) {
  return fetchApi('app/homework/commentDetail', params, "post").then(res => res.data)
}

/**
 * 提交作业
 * @param {*} params 
 */
function submitWork(params) {
  return fetchApi('app/homework/submit', params, "post").then(res => res.data)
}

/**
 * 批改作业
 * @param {} params 
 */
function homeWorkComment(params) {
  return fetchApi('app/homework/comment', params, "post").then(res => res.data)
}

/**
 * 老师跳绳任务列表
 * @param {} params 
 */
function queryTaskRopeList(params) {
  return fetchApi('app/teacher/skipRope/queryTaskRopeList', params, "post").then(res => res.data)
}

/**
 * 添加任务
 * @param {} params 
 */
function addTask(params) {
  return fetchApi('app/teacher/skipRope/addTask', params, "post").then(res => res.data)
}


/**
 * 老师任务详情
 * @param {*} params 
 */
function TaskDetail(params) {
  return fetchApi('app/teacher/skipRope/detail/' + params, {}, "get").then(res => res.data)
}

/**
 * 删除任务
 * @param {*} params 
 */
function delTask(params) {
  return fetchApi('app/teacher/skipRope/del/' + params, {}, "get").then(res => res.data)
}

/**
 * 查询任务当日打卡详情
 * @param {} params 
 */
function queryTeacherSkipRopeDayDetail(params) {
  return fetchApi('app/teacher/skipRope/queryTeacherSkipRopeDayDetail', params, "post").then(res => res.data)
}

/**
 * 提交评论
 * @param {} params 
 */
function commitComment(params) {
  return fetchApi('app/teacher/skipRope/commitComment', params, "post").then(res => res.data)
}
/**
 * 删除评论
 * @param {*} params 
 */
function delComment(params) {
  return fetchApi('app/teacher/skipRope/delComment/' + params, {}, "get").then(res => res.data)
}

/**
 * 新增绑定跳绳
 * @param {*} params 
 */
function addEquipment(params) {
  return fetchApi('app/mqtt/bindRope', params, "post").then(res => res.data)
}

/**
 * 开始跳绳
 * @param {*} params 
 */
function addTaskRopeReq(params) {
  return fetchApi('app/student/skipRope/addTaskRopeReq', params, "post").then(res => res.data)
}

/**
 * 今日跳绳与最近跳绳
 * @param {*} params 
 */
function skipRopeInfo() {
  return fetchApi('app/student/skipRope/skipRopeInfo', {}, "get").then(res => res.data)
}


/**
 * 学生跳绳任务列表
 * @param {} params 
 */
function stuQueryTaskRopeList(params) {
  return fetchApi('app/student/skipRope/queryTaskRopeList', params, "post").then(res => res.data)
}

/**
 * 老师任务详情
 * @param {*} params 
 */
function stuTaskDetail(params) {
  return fetchApi('app/student/skipRope/detail/' + params, {}, "get").then(res => res.data)
}

/**
 * 首页-我的跳绳
 * @param {*} params 
 */
function mySkipRope() {
  return fetchApi('app/student/skipRope/mySkipRope/', {}, "get").then(res => res.data)
}

/**
 * 更新绑定信息
 * @param {*} params 
 */
function updateEquipment(params) {
  return fetchApi('app/student/skipRope/updateEquipment', params, "post").then(res => res.data)
}

/**
 * 解除绑定信息
 * @param {*} params 
 */
function unbindRope(params) {
  return fetchApi('app/mqtt/unbindRope', params, "post").then(res => res.data)
}

/**
 * 更新体重
 * @param {*} params 
 */
function updateWeight(params) {
  return fetchApi('app/mqtt/updateWeight', params, "post").then(res => res.data)
}

/**
 * 查询任务当日打卡详情
 * @param {} params 
 */
function queryStudentSkipRopeDayDetail(params) {
  return fetchApi('app/student/skipRope/queryStudentSkipRopeDayDetail', params, "post").then(res => res.data)
}

/**
 * 设置跳绳模式
 * @param {} params 
 */
function skipMode(params) {
  return fetchApi('app/mqtt/skipMode', params, "post").then(res => res.data)
}

/**
 * 结束跳绳
 * @param {} params 
 */
function endTaskRopeReq(params) {
  return fetchApi('app/student/skipRope/endTaskRopeReq', params, "post").then(res => res.data)
}

/**
 * 历史数据
 * @param {*} params 
 */
function skipRopeHistory(params) {
  return fetchApi('app/student/skipRope/history', params, "post").then(res => res.data)
}
/**
 * 排行榜
 * @param {*} params 
 */
function skipRopeRank(params) {
  return fetchApi('app/student/skipRope/rank', params, "post").then(res => res.data)
}

/**
 * 排行榜
 * @param {*} params 
 */
function musicMode(params) {
  return fetchApi('app/mqtt/musicMode', params, "post").then(res => res.data)
}

/**
 * 获取设备模式
 * @param {*} params 
 */
function getmusicMode() {
  return fetchApi('app/student/skipRope/equipment/musicMode', {}, "get").then(res => res.data)
}
module.exports = {
  Login,
  unionLoginNew,
  searchById,
  searchByIdSatic,
  queryReservationCodes,
  queryReservationCode,
  applyReservationCode,
  queryPackageAssetInfo,
  queryReservationAsset,
  getQRCode,
  queryReservationForPage,
  queryReservationForPageStatic,
  countUserReservationCode,
  isLogin,
  getCurrentTime,
  smproGetCongig,
  queryReservationPartakeNumber,
  queryUserPackageAssetList,
  addReservationAccessCount,
  subscribeWeChatMsg,
  readMsg,
  loginCode,
  mobleLogin,
  getUserInfo,
  weChatLogin,
  homeworkList,
  getTeacherCourset,
  getTeacherCoursetInfo,
  getCoursetStuList,
  getCoursetStuInfo,
  getStudentCourse,
  gesTudentPicture,
  getTeacherStudentInfo,
  loginOut,
  unboundStudent,
  bindingStudent,
  getClassInfo,
  updateUserType,
  standard,
  getSchoolArea,
  updateUserPicUrl,
  getClassInfos,
  applyWork,
  getPrescription,
  getTeachCycle,
  getTestCycle,
  getPrescriptionDetail,
  getStuList,
  getTeacherPrescription,
  getTeacherPrescriptionDetail,
  getPhysicalReportStu,
  getPhysicalReportClass,
  getPhysicalReportTheacher,
  getHomeWorkDetail,
  getParentList,
  getTeacherLis,
  delHomework,
  editHomeWork,
  getHomeworkInfo,
  submitWork,
  homeWorkComment,
  queryTaskRopeList,
  addTask,
  TaskDetail,
  delTask,
  queryTeacherSkipRopeDayDetail,
  commitComment,
  delComment,
  addEquipment,
  addTaskRopeReq,
  skipRopeInfo,
  stuQueryTaskRopeList,
  stuTaskDetail,
  mySkipRope,
  updateEquipment,
  updateWeight,
  unbindRope,
  queryStudentSkipRopeDayDetail,
  skipMode,
  endTaskRopeReq,
  skipRopeHistory,
  skipRopeRank,
  musicMode,
  getmusicMode

}